package com.mgg.goods.service.category.impl;

import java.util.List;

import com.mgg.common.dao.DaoSupport;
import com.mgg.goods.service.category.CategoryService;
import com.mgg.goods.vo.CategoryInfoVO;
import com.mgg.goods.vo.CategoryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;


@Service("categoryService")
public class CategoryServiceImpl implements CategoryService{

	@Autowired
	private DaoSupport dao;

	@Override
	public List<CategoryVO> listCategory(){
		List<CategoryVO> firstCategoryList = dao.findForList("CategoryMapper.listFirstCategory", null);
		for (CategoryVO catg : firstCategoryList) {
			catg.setItems( dao.findForList("CategoryMapper.listSecondCategoryBySuperId", catg.getCategoryId()));
		}
		return firstCategoryList;
	}

	@Override
	public List<CategoryInfoVO> listFirstCategory(){
		List<CategoryInfoVO> categoryList = dao.findForList("CategoryMapper.listFirstCategory", null);
		return categoryList;
	}

	@Override
	public List<CategoryInfoVO> listSecondCategory(String categoryId){
		List<CategoryInfoVO> categoryList = dao.findForList("CategoryMapper.listSecondCategoryBySuperId", categoryId);
		return categoryList;
	}
	
}
